package players;

import java.util.Random;

import staticClasses.Action;

public abstract class Behavior {
	
	/**
	 * To be defined in your sub-class that inherit this class.
	 * this method modify player values like position depending on his
	 * player.nextaction
	 */
	public abstract void execAction();
	
	/**
	 * this class try to choose the best behavior to have, depending on
	 * the situation.
	 * @return the action to do
	 */
	public abstract Action whatToDo();
	
	/**
	 * 
	 * @param opponent_dribble_level the dribble level of the opponent
	 * @param dribble_level the dribble level of the player
	 * @return true if the player achieve dribbling the opponent, false else.
	 */
	public boolean dribble(int opponent_dribble_level, int dribble_level){
		Random r = new Random();
		
		// value between -128 and 127
		int result = 127 - r.nextInt(256);
		
		/*
		 * if the difference between the 2 level is >= 128
		 * one of them will always success in dribble
		 */
		result = result - opponent_dribble_level + dribble_level;
		
		return result >= 0;
	}
}
